package com.itany.corejava.code07_面向对象;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年11月01日 15:43
 */
public class Employee {

    private int id;
    String name;
    protected double salary;
    public String gender;

    //构造方法
    public Employee(int id,String name,double salary,String gender){
        this.id=id;
        this.name=name;
        this.salary=salary;
        this.gender=gender;
        System.out.println("调用的是四个参数的构造方法");
    }

    public void test(){
        System.out.println("这是public修饰的");
    }
    protected void test02(){
        System.out.println("这是protected修饰的");
    }
    void test03(){
        System.out.println("这是没有修饰符的");
    }
    private void test04(){
        System.out.println("这是private修饰的");
    }
    public static void main(String[] args) {

        //同一个类中，所有修饰符修饰的属性均可以访问
        Employee employee=new Employee(1,"alice",9000,"女");
        System.out.println(employee.id);
        System.out.println(employee.name);
        System.out.println(employee.salary);
        System.out.println(employee.gender);
        employee.test();
        employee.test02();
        employee.test03();
        employee.test04();


    }

}

class Emp{
    private int id;
    String name;
    protected double salary;
    public String gender;
    public Emp(){
        System.out.println("这是一个无参数的构造方法");
    }
}
